package com.spa.infrastructure.mapper;

import com.spa.domain.entity.Refund;
import com.spa.infrastructure.repository.po.RefundPO;
import com.spa.infrastructure.service.wx.result.RefundSuccessResult;
import org.mapstruct.Mapper;
import org.mapstruct.MapperConfig;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
@MapperConfig(unmappedTargetPolicy = ReportingPolicy.WARN)
public interface RefundMapperStruct {

    RefundMapperStruct INSTANCE = Mappers.getMapper(RefundMapperStruct.class);

    @Mapping(source = "transaction_id", target = "transactionId")
    @Mapping(source = "out_trade_no", target = "outTradeNo")
    @Mapping(source = "out_refund_no", target = "outRefundNo")
    @Mapping(source = "refund_id", target = "refundId")
    @Mapping(source = "refund_status", target = "refundStatus")
    @Mapping(source = "user_received_account", target = "userReceivedAccount")
    @Mapping(source = "success_time", target = "successTime")
    @Mapping(source = "amount.total", target = "total")
    @Mapping(source = "amount.refund", target = "refund")
    @Mapping(source = "amount.payer_total", target = "payerTotal")
    @Mapping(source = "amount.payer_refund", target = "payerRefund")
    RefundPO command2Po(RefundSuccessResult result);

    List<Refund> po2EntityList(List<RefundPO> po);

    //    @Mapping(source = "transaction_id", target = "transactionId")
//    @Mapping(source = "out_trade_no", target = "outTradeNo")
//    @Mapping(source = "out_refund_no", target = "outRefundNo")
//    @Mapping(source = "refund_id", target = "refundId")
//    @Mapping(source = "refund_status", target = "refundStatus")
//    @Mapping(source = "user_received_account", target = "userReceivedAccount")
//    @Mapping(source = "success_time", target = "successTime")
//    @Mapping(source = " payer_total", target = "payerTotal")
//    @Mapping(source = " payer_refund", target = "payerRefund")
    Refund po2Entity(RefundPO po);
}
